#!/usr/bin/env jruby

require 'test/unit'
dir = File.dirname(__FILE__)
require File.join(dir, '..', '..', 'lib', 'monkey', 'object')

########################################

class TestObjectIsAKindOf < Test::Unit::TestCase
  STRING = 'foo'
  METHODS = [:is_a?, :kind_of?]
  
  def test_should_require_at_least_one_arg
    METHODS.each do |meth|
      assert_nothing_thrown('String') { STRING.send(meth, String) }
      assert_nothing_thrown('H & S') { STRING.send(meth, Hash, String) }
      assert_raise(ArgumentError) { STRING.send(meth) }
    end
  end
  
  def test_should_return_boolean
    METHODS.each do |meth|
      result1 = STRING.send(meth, String)
      assert (result1.class==TrueClass or result1.class==FalseClass), '1'
      result2 = STRING.send(meth, Fixnum)
      assert (result2.class==TrueClass or result2.class==FalseClass), '2'
    end
  end
  
  def test_should_return_true
    METHODS.each do |meth|
      assert_equal true, STRING.send(meth, String), 'String'
      assert_equal true, STRING.send(meth, String, Hash), 'S & H'
      assert_equal true, STRING.send(meth, Hash, String), 'H & S'
    end
  end
  
  def test_should_return_false
    METHODS.each do |meth|
      assert_equal false, STRING.send(meth, Fixnum, Array), 'F & A'
      assert_equal false, STRING.send(meth, Fixnum), 'Fixnum'
    end
  end
end
